package com.whfc.iot.mach.codec;

import com.whfc.iot.mach.constant.MsgConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/29 15:21
 */
public class MachMsgDataCodecFactory {

    private static Logger logger = LoggerFactory.getLogger(MachMsgDataCodecFactory.class);

    private static MachMsgDataCodec0x01 codec0x01 = new MachMsgDataCodec0x01();
    private static MachMsgDataCodec0x02 codec0x02 = new MachMsgDataCodec0x02();
    private static MachMsgDataCodec0x04 codec0x04 = new MachMsgDataCodec0x04();
    private static MachMsgDataCodec0x05 codec0x05 = new MachMsgDataCodec0x05();
    private static MachMsgDataCodec0x06 codec0x06 = new MachMsgDataCodec0x06();
    private static MachMsgDataCodec0x08 codec0x08 = new MachMsgDataCodec0x08();
    private static MachMsgDataCodec0x09 codec0x09 = new MachMsgDataCodec0x09();
    private static MachMsgDataCodec0x0A codec0x0A = new MachMsgDataCodec0x0A();
    private static MachMsgDataCodec0x0B codec0x0B = new MachMsgDataCodec0x0B();
    private static MachMsgDataCodec0x0C codec0x0C = new MachMsgDataCodec0x0C();

    private static MachMsgDataCodec0x81 codec0x81 = new MachMsgDataCodec0x81();
    private static MachMsgDataCodec0x82 codec0x82 = new MachMsgDataCodec0x82();
    private static MachMsgDataCodec0x83 codec0x83 = new MachMsgDataCodec0x83();
    private static MachMsgDataCodec0x84 codec0x84 = new MachMsgDataCodec0x84();
    private static MachMsgDataCodec0x85 codec0x85 = new MachMsgDataCodec0x85();
    private static MachMsgDataCodec0x86 codec0x86 = new MachMsgDataCodec0x86();
    private static MachMsgDataCodec0x87 codec0x87 = new MachMsgDataCodec0x87();
    private static MachMsgDataCodec0x88 codec0x88 = new MachMsgDataCodec0x88();
    private static MachMsgDataCodec0x89 codec0x89 = new MachMsgDataCodec0x89();
    private static MachMsgDataCodec0x8A codec0x8A = new MachMsgDataCodec0x8A();
    private static MachMsgDataCodec0x8B codec0x8B = new MachMsgDataCodec0x8B();
    private static MachMsgDataCodec0x8C codec0x8C = new MachMsgDataCodec0x8C();

    public static MachMsgDataCodec getMsgDataCodec(Integer cmd) {
        MachMsgDataCodec bodyCodec = null;
        switch (cmd) {
            case MsgConst.UPSTREAM_CMD_0x01:
                bodyCodec = codec0x01;
                break;
            case MsgConst.UPSTREAM_CMD_0x02:
                bodyCodec = codec0x02;
                break;
            case MsgConst.UPSTREAM_CMD_0x03:
                break;
            case MsgConst.UPSTREAM_CMD_0x04:
                bodyCodec = codec0x04;
                break;
            case MsgConst.UPSTREAM_CMD_0x05:
                bodyCodec = codec0x05;
                break;
            case MsgConst.UPSTREAM_CMD_0x06:
                bodyCodec = codec0x06;
                break;
            case MsgConst.UPSTREAM_CMD_0x08:
                bodyCodec = codec0x08;
                break;
            case MsgConst.UPSTREAM_CMD_0x09:
                bodyCodec = codec0x09;
                break;
            case MsgConst.UPSTREAM_CMD_0x0A:
                bodyCodec = codec0x0A;
                break;
            case MsgConst.UPSTREAM_CMD_0x0B:
                bodyCodec = codec0x0B;
                break;
            case MsgConst.UPSTREAM_CMD_0x0C:
                bodyCodec = codec0x0C;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x81:
                bodyCodec = codec0x81;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x82:
                bodyCodec = codec0x82;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x83:
                bodyCodec = codec0x83;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x84:
                bodyCodec = codec0x84;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x85:
                bodyCodec = codec0x85;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x86:
                bodyCodec = codec0x86;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x87:
                bodyCodec = codec0x87;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x88:
                bodyCodec = codec0x88;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x89:
                bodyCodec = codec0x89;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x8A:
                bodyCodec = codec0x8A;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x8B:
                bodyCodec = codec0x8B;
                break;
            case MsgConst.DOWNSTREAM_CMD_0x8C:
                bodyCodec = codec0x8C;
                break;
            default:
                logger.info("无法解析的指令,cmd:{}", cmd);
                break;
        }
        return bodyCodec;
    }
}
